<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            position: relative;
            width: 200px;
            height: 200px;
            background: red;
        }

        .child1 {
            width: 50px;
            height: 50px;
            background: yellow;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1000;
        }
        .child2 {
            width: 50px;
            height: 50px;
            background: green;
            position: absolute;
            top: 10px;
            left: 10px;
            z-index: 1;
        }
        .child3 {
            width: 50px;
            height: 50px;
            background: blue;
            position: absolute;
            top: 20px;
            left: 20px;
            z-index: 100;
        }
    </style>
</head>
<body>
    <!-- z-index控制已定位元素的堆叠顺序 -->
    <!-- 
        前提：平级的兄弟元素
        默认，后声明的元素，压在先声明的元素上

        z-index值越大，层叠优先级越高

        特殊点：父子元素，子元素永远压在父元素上
     -->
    <div class="box">
        <div class="child1"></div>
        <div class="child2"></div>
        <div class="child3"></div>
    </div>
</body>
</html>